package com.ld.collegetask.utils;

import android.app.Application;
import android.content.pm.PackageInfo;
import android.content.pm.PackageManager;
import android.content.res.Resources;
import android.util.DisplayMetrics;

import com.ld.collegetask.chatting.utils.SharePreferenceManager;

import cn.jpush.android.api.JPushInterface;
import cn.jpush.im.android.api.JMessageClient;

/**
 * Created by heliang on 2017/5/4.
 */

public class AppApplication extends Application {
    public static String platform = "android";
        public static String server = "http://solomanhl.3322.org:8888/whld/";
//    public static String server = "http://192.168.1.6:8080/whld/";
    private int pixelWidth, pixelHeight;
    private float density;

    @Override
    public void onCreate() {
        super.onCreate();
        JPushInterface.init(this);//极光推送
        JMessageClient.setDebugMode(true);
        JMessageClient.init(this, true);
        //设置Notification的模式
        JMessageClient.setNotificationMode(JMessageClient.NOTI_MODE_NO_NOTIFICATION);
        //初始化SharePreference
        SharePreferenceManager.init(this, "global_collegetask_is_im");
    }

    /**
     * 2  * 获取版本号
     * 3  * @return 当前应用的版本号
     * 4
     */
    public String getVersion() {
        try {
            PackageManager manager = this.getPackageManager();
            PackageInfo info = manager.getPackageInfo(this.getPackageName(), 0);
            String version = info.versionName;
            return version;
        } catch (Exception e) {
            e.printStackTrace();
            return "";
        }
    }

    public void getScreenPara() {
        Resources resources = this.getResources();
        DisplayMetrics dm = resources.getDisplayMetrics();
        setDensity(dm.density);
        setPixelWidth(dm.widthPixels);
        setPixelHeight(dm.heightPixels);
    }

    public int getPixelWidth() {
        return pixelWidth;
    }

    public void setPixelWidth(int pixelWidth) {
        this.pixelWidth = pixelWidth;
    }

    public int getPixelHeight() {
        return pixelHeight;
    }

    public void setPixelHeight(int pixelHeight) {
        this.pixelHeight = pixelHeight;
    }

    public float getDensity() {
        return density;
    }

    public void setDensity(float density) {
        this.density = density;
    }


}
